<template>
	<view class="">
		<view class="comtop" style="background-color: #efefef;height: 11vh;align-items: flex-end;">
			<view class="comtxt" style="margin-bottom: 20rpx;display: flex;" @click="goback">
				<u-icon name="arrow-left" color="#000000" size="24"></u-icon>
				<text style="display: block;margin-left: 20rpx;">推广企业列表</text>
			</view>
		</view>
		<view class="tgcomtop">
			<view style="display: flex;width: 100%;justify-content: space-between;height: 100%;">
				<view style="width: 40%;margin: 20rpx auto;margin-left: 50rpx;">
					<view>企业推广数：<text style="font-size: 60rpx;">{{entPassTotal}}</text></view>
					<!-- <view style="color: gray;">间接推广数：<text style="font-size: 40rpx;">{{entPassTotal}}</text></view> -->
				</view>
				<img src="https://xgr.oss-cn-hangzhou.aliyuncs.com/icon/enterprise_base_logo.png"  alt="" style="height: 80%;width: 60%;margin-top: 40rpx;" />
			</view>
			
			<view class="" v-if="comlist.length == 0">
				<u-divider text="您暂无推广企业"></u-divider>
			</view>
		</view>
		<!-- <view class="bar" style="background-color: white;border-radius: 10rpx;">
			<u-tabs :list="tabList" @click="change" :scrollable='false' lineWidth = '25' lineHeight = '4'  :current="current"  ></u-tabs>
		</view> -->
		<!-- 直推 -->
		<view class="com-contain" v-if="current==0" v-for="(item,index) in comlist" :key="item.id" @click="item.status == 1 ? navToinfo(item) : ''" style="position: relative;">
			<view class="com-avatar">
				<image :src="item.cloge ? item.cloge : 'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/default-avatar.png'" mode="" style="width: 100%; height: 100%;"></image>
			</view>
			<view class="com-containtxt" >
				<view class="tptxt">
					<text v-if="item.status == 1">{{item.cname}}</text>
					<text v-if="item.status == 0"style="color: #FF3C3C;">企业资质审核未通过</text>
					<text v-if="item.status == 2" style="color: #FF8400;">企业资质待审核</text>
					<view v-if="item.status == 1" class="aut" style="background-color: #E6FFF2;color: #10A22D;">已通过</view>
				</view>
				<text  v-if="item.status == 0" class="bmtxt">审核未通过，请上传符合要求的图片</text>
				<text  v-if="item.status == 2" class="bmtxt">审核完成后，显示企业相关信息</text>
				<text  v-if="item.status == 1" class="bmtxt">{{item.cnature?item.cnature:''}} {{item.cindustry? '|' : ''}} {{item.cindustry?item.cindustry:''}} {{item.remark1? '|' : ''}} {{item.remark1?item.remark1:''}}</text>
				<!-- <view class="delbtn"  @click.stop="delfillcom">
					<image src="https://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/delete.svg" mode="" style="width: 40rpx; height: 40rpx;"></image>
				</view> -->
			</view>
		</view>
		<!-- 间推 -->
		<view class="com-contain" v-if="current==1" v-for="(item,index) in comlist" :key="item.id" @click="item.status == 1 ? navToinfo(item) : ''" style="position: relative;">
			<view class="com-avatar">
				<image :src="item.cloge ? item.cloge : 'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/default-avatar.png'" mode="" style="width: 100%; height: 100%;"></image>
			</view>
			<view class="com-containtxt" >
				<view class="tptxt">
					<text v-if="item.status == 1">{{item.cname}}</text>
					<text v-if="item.status == 0"style="color: #FF3C3C;">企业资质审核未通过</text>
					<text v-if="item.status == 2" style="color: #FF8400;">企业资质待审核</text>
					<view v-if="item.status == 1" class="aut" style="background-color: #E6FFF2;color: #10A22D;">已通过</view>
				</view>
				<text  v-if="item.status == 0" class="bmtxt">审核未通过，请上传符合要求的图片</text>
				<text  v-if="item.status == 2" class="bmtxt">审核完成后，显示企业相关信息</text>
				<text  v-if="item.status == 1" class="bmtxt">{{item.cnature?item.cnature:''}} {{item.cindustry? '|' : ''}} {{item.cindustry?item.cindustry:''}} {{item.remark1? '|' : ''}} {{item.remark1?item.remark1:''}}</text>
				<!-- <view class="delbtn"  @click.stop="delfillcom">
					<image src="https://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/delete.svg" mode="" style="width: 40rpx; height: 40rpx;"></image>
				</view> -->
			</view>
		</view>
		<!-- <view v-if="!isonReachBottom"  style="text-align: center; color: #333; line-height: 100rpx; background: #f3f3ff;">没有更多了...</view> -->
	</view>
	
</template>

<script>
	//已注册企业
	import Index from "@/common/index-model.js"	
	import fun from '@/common/publicFun.js'
	let index = new Index()
	let that = null
	export default {
		data() {
			return {
				id:0,
				comlist:[],
				ps:10,
				pn:0,
				isonReachBottom:true,
				entPassTotal:0,
				current:0,
				// tabList: [{
				// 		name: '直推'
				// 	},
				// 	{
				// 		name: '间推'
				// 	}
				// ],
			}
		},
		onLoad(opt) {
			this.id = opt.id
			this.getcompany()
			this.getpasstotal()
		},
		onPullDownRefresh() {
			this.getcompany()
		  },
		onReachBottom() {
			if(this.isonReachBottom&&this.comlist.length == 10){
				console.log(this.isonReachBottom)
				this.getcompany()
			}
			
		},
		methods: {
			// change(index) {
			// 	console.log(index.index,"点击")
			// 	this.current = index.index;
			// },
			delfillcom(){
				console.log('删除审核失败公司')
			},
			goback(){
				uni.navigateBack()
			},
			//页面跳转
			navToinfo(e) {
				let comtginfo = JSON.stringify(e);
				index.navigate_to(`/pagesC/compyinfo/index?index=` + comtginfo + '&&istg=1')
			},
			getcompany(){
				index.getPublicUserMember({
					pageSize:this.ps,
					pageNo:this.pn,
					pId:this.id
					// pId:188
					// pageSize:100,
					//  pageNo:0,
				},'client/enterprise/info/enterpriseByInvitePId','get',res=>{
					if(res.data.code == 200 && res.data.success){
						console.log("请求数据->",res.data.result.records) 
						if(this.comlist.length != res.data.result.records.length){
							this.ps += 10
						}else{
							this.isonReachBottom = false
						}
						this.comlist = res.data.result.records
						uni.stopPullDownRefresh();
					}else{
						console.log("请求失败") 
						uni.stopPullDownRefresh();
					}
				})
				console.log("请求数据",this.comlist)
			},
			getpasstotal(){
				index.getPublicUserMember({
					pId:this.id
				},'client/enterprise/info/enterCountByInvitePId','get',res=>{
					if(res.data.code == 200 && res.data.success){
						console.log('通过',res.data)
						this.entPassTotal = res.data.result.succCount
					}else{
						console.log("请求失败") 
					}
				})
			}
		}
	}
</script>

<style>
	@import url("../compy/index.css");
	page{
		width: 100%;height: 100%;background-color: #efefef;
	}
.delbtn{
	position: absolute;right: 30rpx;top: 60rpx;
	width: 70rpx;
	height: 70rpx;
	/* background-color: red; */
	display: flex;
	align-items: center;
	justify-content: center;
}
.tgcomtop{
	height: 200rpx;
}
</style>
